//
//  SMSourceTableRowView.swift
//  SmartMachine
//
//  Created by Sherman's iMac on 2019/11/6.
//  Copyright © 2019 Smart. All rights reserved.
//

import Cocoa

class SMSourceTableRowView: NSTableRowView {

    var titleLab : NSTextField!
    
    override func draw(_ dirtyRect: NSRect) {
        super.draw(dirtyRect)

        // Drawing code here.
    }
    
    override init(frame frameRect: NSRect) {
        
        super.init(frame: frameRect)
        setup()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        
        setup()
    }
    
    func setup() {
        
        self.selectionHighlightStyle = NSTableView.SelectionHighlightStyle.none
        
        titleLab = NSTextField.init(frame: NSZeroRect)
        titleLab.font = NSFont.boldSystemFont(ofSize: 16)
        titleLab.textColor = NSColor.black
        titleLab.isEditable = false
        titleLab.drawsBackground = false
        titleLab.isBordered = false
        
        self.addSubview(titleLab)
        
        titleLab.snp.makeConstraints { (make) in
            
            make.left.equalToSuperview().offset(10.0)
            make.right.equalToSuperview().offset(-10.0)
            make.centerY.equalToSuperview()
        }
    }  
} 



class SMTreeTableRowView: NSTableRowView {

    var titleLab : NSTextField!
    
    override func draw(_ dirtyRect: NSRect) {
        super.draw(dirtyRect)

        // Drawing code here.
    }
    
    override init(frame frameRect: NSRect) {
        
        super.init(frame: frameRect)
        
//        selectionHighlightStyle = NSTableView.SelectionHighlightStyle.none
        setup()
    }
    
    override var interiorBackgroundStyle: NSView.BackgroundStyle
        {
        get {
            return NSView.BackgroundStyle.normal;
        }
    }
    
//    override var selectionHighlightStyle: NSTableView.SelectionHighlightStyle {
//
//        get {
//            return NSTableView.SelectionHighlightStyle.none;
//        }
//    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        
        setup()
    }
    
    func setup() {
        
        self.selectionHighlightStyle = NSTableView.SelectionHighlightStyle.none
        
        titleLab = NSTextField.init(frame: NSZeroRect)
        titleLab.font = NSFont.boldSystemFont(ofSize: 16)
        titleLab.textColor = NSColor.black
        //FUNC_COLOR(r: 240, g: 240, b: 240);
        titleLab.isEditable = false
        titleLab.drawsBackground = false
        titleLab.isBordered = false
        
        self.addSubview(titleLab)
        
        titleLab.snp.makeConstraints { (make) in
            
            make.left.equalToSuperview().offset(10.0)
            make.right.equalToSuperview().offset(-10.0)
            make.centerY.equalToSuperview()
        }
    }
}

